<?php
App::uses('AuthComponent', 'Controller/Component');
/**
 * MyAuthComponent
 *
 * @package		app.Controller.Components
 * @author		Mark Vink
 *
 * @property    Cookie $CookieComponent
 *
 */
class MyAuthComponent extends AuthComponent {

    public $components = array('Session', 'Cookie', 'RequestHandler');

    public function login($user = null) {
        if(parent::login($user)) {
            $userModel = ($this->authenticate[AuthComponent::ALL]['userModel']) ? $this->authenticate[AuthComponent::ALL]['userModel'] : 'User';
            if(!empty($this->request->data[$userModel]['remember'])) {
                $this->Cookie->write(parent::$sessionKey, $this->request->data, true);
            }
        }
        return $this->loggedIn();
    }
}